<?php
/**
* 跨境电商商城系统
 * =============================================
 * Copy right 2016-2026 大连熠泽科技网络有限公司
 * ---------------------------------------------
 * 官方网址: http://www.yizehuitong.com
 * =============================================
 * @author : yizehuitong
 * @date : 2019.10
 * @version : v2.0
 */
namespace data\model;

use data\model\BaseModel as BaseModel;
/**
 * 商品浏览足迹表
 * @author Administrator
 *
 */
class NsGoodsBrowseModel extends BaseModel {

    protected $table = 'ns_goods_browse';
    protected $rule = [
        'browse_id'  =>  '',
    ];
    protected $msg = [
        'browse_id'  =>  '',
    ];


    /**
     * 获取列表返回数据格式
     * @param $page_index
     * @param $page_size
     * @param $condition
     * @param $order
     * @return array
     */
    public function getGoodsBrowseViewList($page_index, $page_size, $condition, $order){

        $queryList = $this->getGoodsBrowseViewQuery($page_index, $page_size, $condition, $order);
        $queryCount = $this->getGoodsBrowseViewCount($condition);
        $list = $this->setReturnList($queryList, $queryCount, $page_size);
        return $list;
    }


    /**
     * 获取足迹列表数据
     * @param $page_index
     * @param $page_size
     * @param $condition
     * @param $order
     * @return array
     */
    public function getGoodsBrowseViewQuery($page_index, $page_size, $condition, $order)
    {
        $viewObj = $this->alias('ngb')
            ->join('ns_goods ng','ngb.goods_id = ng.goods_id','left')
            ->field('ngb.*');
        $list = $this->viewPageQuery($viewObj, $page_index, $page_size, $condition, $order);
        return $list;
    }

    /**
     * 获取足迹列表数量
     * @param $condition
     * @return int
     */
    public function getGoodsBrowseViewCount($condition)
    {
        $viewObj = $this->alias('ngb')
            ->join('ns_goods ng','ngb.goods_id = ng.goods_id','left')
            ->field('ngb.browse_id');
        $count = $this->viewCount($viewObj, $condition);
        return $count;
    }

}